<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    xmlns:f="http://java.sun.com/jsf/core"
	    xmlns:h="http://java.sun.com/jsf/html"
	    xmlns:ui="http://java.sun.com/jsf/facelets"
	    xmlns:p="http://primefaces.org/ui"
	    template="/template/template.xhtml">
    
   	<ui:param name="pageTitle" value="Cadastro de Edital" />
   	
    <ui:define name="body"> 
    	<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  
              
		<p:dialog modal="true" widgetVar="statusDialog" header="Carregando..."   
		        draggable="false" closable="false">  
		    <p:graphicImage value="/resources/images/ajaxloadingbar.gif" />  
		</p:dialog>  
    	<h:form id="formLance">  
    	<p:growl id="msgs"/> 
	    <p:panelGrid id="lance" style="margin-top:20px;width:800px;margin-left:auto;margin-right:auto;box-shadow:1px 1px 12px #333;" >  
		    <f:facet name="header">  
		        <p:row>  
		            <p:column colspan="8">#{lanceController.edital.nome}</p:column>  
		        </p:row>  
		        <p:row>  
		            <p:column colspan="3" style="text-align:left;">Data In&iacute;cio</p:column>
		            <p:column colspan="3" style="text-align:left;">Data Fim</p:column>
		            <p:column colspan="2" style="text-align:right;">Pre&ccedil;o</p:column>
		        </p:row>  
		    </f:facet>  
  
		    <p:row>
		        <p:column colspan="3">#{lanceController.edital.dataInicio}</p:column>  
		        <p:column colspan="3">#{lanceController.edital.dataFim}</p:column> 
		        <p:column colspan="2" style="text-align:right;">R$ #{lanceController.edital.precoInicial}</p:column> 
		    </p:row>
		    <p:row>  
		        <p:column colspan="8" styleClass="ui-widget-header">  
		            <p:spacer height="0"/>  
		        </p:column>  
		    </p:row>  
		     <p:row>  
		            <p:column colspan="8" style="text-align:left;" styleClass="ui-widget-header">Descri&ccedil;&atilde;o</p:column>
		     </p:row>
		     <p:row>  
		            <p:column colspan="8" style="text-align:left;">#{lanceController.edital.descricao}</p:column>
		     </p:row>  
		     <p:row>  
		        <p:column colspan="8" styleClass="ui-widget-header">  
		            <p:spacer height="0"/>  
		        </p:column>  
		    </p:row>
		     <p:row>  
		            <p:column colspan="4" style="text-align:left;" styleClass="ui-widget-header">Produto</p:column>
		            <p:column colspan="4" style="text-align:right;" styleClass="ui-widget-header">Quantidade</p:column>
		     </p:row>
		     <p:row>  
		            <p:column colspan="4" style="text-align:left;">#{lanceController.edital.produto.nome}</p:column>
		            <p:column colspan="4" style="text-align:right;">#{lanceController.edital.quantidade}</p:column>
		     </p:row>  
		     <p:row>  
		        <p:column colspan="8" styleClass="ui-widget-header">  
		            <p:spacer height="0"/>  
		        </p:column>  
		    </p:row>
		     <p:row>
		        <p:column colspan="4" styleClass="ui-widget-header">&Uacute;ltimo Lance</p:column>  
		        <p:column colspan="4" style="text-align:right;" styleClass="ui-widget-header">&Uacute;ltimo Usu&aacute;rio</p:column> 
		    </p:row>
		     <p:row>
		        <p:column colspan="4"><h:outputText id="txtLance" value="R$ #{lanceController.lanceAtual.lance}"/></p:column>
		        <p:column colspan="4" style="text-align:right;"><h:outputText id="txtUsuarioLance" value="R$ #{lanceController.lanceAtual.usuario.nome}"/></p:column> 
		    </p:row>
		     <p:row>  
		        <p:column colspan="8" styleClass="ui-widget-header">  
		            <p:spacer height="0"/>  
		        </p:column>  
		    </p:row>
  			
  
		    <f:facet name="footer">  
		    	 <p:row>  
		            <p:column  colspan="8" style="text-align:center;">  
		               Valor do Lance <br></br> 
		               <p:inputText value="#{lanceController.lance.lance}" id="inputLance" 
		               				style="position:absolute;margin-left: -100px;z-index:9999;"
		               				required="true" 
			            			requiredMessage="Por favor, digite o valor do lance"
		               				styleClass="precoLance"
			            			converter="precoConverter"
			            			onfocus="$('.precoLance').maskMoney({showSymbol:true, symbol:'R$',thousands:'.', decimal:','});"
		               /> 
		            </p:column>  
		        </p:row>
		        <p:row>  
		            <p:column  colspan="8" style="text-align:center;">  
		                <p:commandButton 
		                action="#{lanceController.efetuarLance()}"
		                update=":formLance:lance,:formLance:msgs,:formLance:inputLance"
						value="DAR LANCE!"
						icon="ui-icon-flag"
						style="margin-top: 39px;margin-bottom: 14px;" />  
		            </p:column>  
		        </p:row>  
		    </f:facet>  
		</p:panelGrid>
		<p:poll interval="10" listener="#{lanceController.pollLanceAtual}" update="txtLance,txtUsuarioLance"/>  
	</h:form> 
			
    </ui:define>
</ui:composition>